extends CharacterBody2D


@onready var move: MoveComponent = $CharacterComponent/Move/MoveComponent
@onready var face: MoveComponent = $CharacterComponent/Face/MoveComponent
@onready var body_ani: AnimatedSprite2D = $Body/AnimatedSprite2D


@export var knapsak_container: Container = null
@export var equip_container: Container = null
@export var buff_container: Container = null


func play_animation(animation_name: String, is_play_back: bool = false) -> void:
    if body_ani.animation != animation_name:
        if is_play_back:
            body_ani.play_backwards(animation_name)
        else:
            body_ani.play(animation_name)

func _physics_process(delta: float) -> void:
    if move.is_moving():
        play_animation("run", sign(move.direction.x) != sign(face.direction.x))
    else:
        play_animation("idle")
